﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Web_Pages_UserControls_CreateUserProfiles : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

   
    protected void btcTao_Click(object sender, EventArgs e)
    {
        UsersBLL userBll = new UsersBLL();
        
        Users user = (Users)Session["User"];

        String names = this.txtTaikhoan.Text;

        Boolean gender = true;

        if (rdNam.Checked)
        {
            gender = false;
        }

        //  String ngaysinh = cboNgaysinh.SelectedValue +"/"+ cboThang.SelectedValue +"/"+ cboNam.SelectedValue;

        //  DateTime dateBirth = DateTime.ParseExact(ngaysinh, "dd/MM/yyyy",null);
        DateTime dateBirth = Convert.ToDateTime(txtNgaySinh_CalendarExtender.SelectedDate);

        String city = "Hồ Chí Minh";
        String people = this.cboDantoc.SelectedValue;
        String avatar = "thayngoc.jpg";
        String interest = this.txtSothich.Text;
        String jobs = this.txtNghenghiep.Text;
        DateTime createTime = DateTime.Now;

        try
        {
            bool kq = userBll.GetIUserProfiles.CreateUserProfile(user, names, gender, dateBirth, city, people, avatar, interest, jobs, createTime);
            if (kq == true)
            {

                //Response.Redirect(Request.UrlReferrer.ToString());
                Response.Redirect("Home.aspx");

            }
            else
            {
                Response.Redirect("Fail.aspx");
            }
        }
        catch
        {
            Response.Write("<script>alert('Cap nhat khong thanh cong')</script>");
        }
        String a = txtNgaySinh.Text;
        Response.Write(a);
    }
}